/**   
 * @Title: Dao.java 
 * CopyRight(c)2010-DMX 
 */
package com.dmx.fw.dao.interfaces;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.dmx.fw.bean.PageInfo;


/**
 * @Description:Data Access Object (Dao) interface.   This is an interface
 *  used to tag our Dao classes and to provide common methods to all Daos.
 * @author: system
 * @date: 2006
 * @version V1.0 
 * 
 */
public interface Dao {
	
	public void flush();

    /**
     * @Description Generic method used to get all objects of a particular type. This
     * is the same as lookup up all rows in a table.
     * @param clazz the type of objects (a.k.a. while table) to get data from
     * @return List of populated objects
     */
    public List getObjects(Class clazz);
    
    /**
     * @Description Generic method to get an object based on class and identifier. An 
     * ObjectRetrievalFailureException Runtime Exception is thrown if 
     * nothing is found.
     * 
     * @param clazz model class to lookup
     * @param id the identifier (primary key) of the class
     * @return a populated object
     * @see org.springframework.orm.ObjectRetrievalFailureException
     */
    public Object getObject(Class clazz, Serializable id);
    
    
    public List getObjects(Class clazz,Serializable[] id);
    public List getObjectsByCriteria(final DetachedCriteria detachedCriteria)throws Exception;
    public List getObjectsByCriteria(final DetachedCriteria detachedCriteria,final PageInfo pageInfo)throws Exception;
    /**
     * @Description Generic method to save an object - handles both update and insert.
     * @param o the object to save
     */
    public void saveObject(Object o) throws Exception;
    public void updateObject(Object o);
    /**
     * @Description Generic method to delete an object based on class and id
     * @param clazz model class to lookup
     * @param id the identifier (primary key) of the class
     */
    public void removeObject(Class clazz, Serializable id);
    public void removeObject(Object o);
    
    /**
     * @Description Generic method to get objects by hql
     * @param  hqlString: hql
     * @return List
     */
    public List find(String hqlString);
    
    /**
     * @Description Generic method to get objects by hql
     * @param hqlString: hql
     * @param value
     * @return List
     */ 
    public List find(String hqlString,Object value);
    
    /**
     * @Description Generic method to get objects by hql
     * @param  hqlString: hql
     * @param values
     * @return List
     */
    public List find(String hqlString,Object[] values);
    
    /**
     * @Description Generic method to save an object - handles both update and insert.
     * @param o the object to save
     * @return Long: id
     */
    public Long create(Object o);
    
    public void saveAll(Collection entities) throws Exception;
}
